<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <script>
        let arr = [12, 21, 55, 34, 88, 75, 21, 21, 43, 12, 34, 75]

        function sortFn3(arr) {
            for (let i = 0; i < arr.length - 1; i++) {
                for (let j = 0; j < arr.length - 1 - i; j++) {
                    if (arr[j] > arr[j + 1]) {
                        [arr[j], arr[j + 1]] = [arr[j + 1], arr[j]]
                    }

                }
            }
        }

        sortFn3(arr)

        function sortFn2(arr) {
            for (let i = 0; i < arr.length; i++) {
                for (let j = i + 1; j < arr.length; j++) {
                    if (arr[i] < arr[j]) {
                        [arr[i], arr[j]] = [arr[j], arr[i]]
                    }

                }
            }
        }
        // sortFn2(arr)
        // console.log(sortFn2(arr));

        function sortFn(arr) {
            return arr.sort((a, b) => a - b)
        }
        // sortFn(arr)
        // console.log(arr);

        //斐波那契
        function fbnq(n) {
            if (n < 2) return n
            return fbnq(n - 1) + fbnq(n - 2)
        }
        // fbnq(1)
        // console.log(fbnq(10));

        let hih = [22, 33, 44, 55,1]
        let hoh = hih.reduce((a, e, i, o) => {
            console.log(a);
            console.log(e);
            console.log(i);
            return a += e
        })

        console.log(hoh);
    </script>
</body>

</html>